<?include ($_SERVER ["DOCUMENT_ROOT"] . "/lib/module/conn_db.php");?>
<?include ($_SERVER ["DOCUMENT_ROOT"] . "/lib/module/Util.php");?>
<?php //DB Open

	$result = null;
	$db = new MyDB ( false );
	$db->err_report = true;

?>
<?php

	$util = new Util();

	$page = $_GET ["page"];

	if (!$page)	$page = 1;

	$pern = 8;
	$perb = 10;

	$sid = $_GET['sid'];

	$addStr = "sid=".$sid;

	$sql = "SELECT category_name, category_hanja from tb_category WHERE category_sid=".$sid;
	$db->query ( $sql );
	$query = $db->result;
	$row = mysql_fetch_object($query);

	$sql = "SELECT * from tb_banner WHERE category_sid=".$sid." ORDER BY banner_sid DESC";
	$db->query ( $sql );
	$query = $db->result;
	$total = mysql_num_rows ($query);

//	if ($total > 0) {
//
//		$lastpage = ceil( $total / $pern );
//		if ( $page > $lastpage ) $page = $lastpage;
//		$first = ( $page - 1 ) * $pern;
//
		// 페이징 목록
//		$lastbl = ceil ( $lastpage / $perb );
//		$bl = ceil ( $page / $perb );
//		$stpage = ($bl - 1) * $perb + 1;
//		$edpage = ($bl - 1) * $perb + $perb;
		// 글번호
//		$start_no = $total - (($page - 1) * $pern);
//
//		$sql .= " limit $first, $pern ";
//
//
		$db->query ( $sql );
		$result = $db->result;
//		$to = mysql_num_rows ($result);
//	}
	$i=0;


?>
<?php //DB Close

	$db->close ();

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<? include "inc/inc_header.php" ?><!-- header -->
 <body style="background-color:transparent"  oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		  <td>
			<?php if($total>0):?>
				<?php while($rows = mysql_fetch_object($result)):?>
				  <?php if($i%4==0):?>
					  <table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
				  <?php endif;?>
						  <td width="25%" valign="top" style="padding-bottom:30px;"><table width="210" border="0" cellspacing="0" cellpadding="0">
							  <tr>
								<td><table width="210" border="0" cellpadding="0" cellspacing="1" bgcolor="#AFAFAF">
									<tr>
									  <td><a href="<?php echo $rows->banner_url;?>" class="su" target="_blank"><img src="uploads/banner/<?php echo $rows->banner_file;?>" width="208" height="76" border="0" title="<?php echo $rows->banner_exp2;?>/<?php echo $row->category_name;?>[<?php echo $row->category_hanja;?>]"></a></td>
									</tr>
								</table></td>
							  </tr>
							  <tr>
								<td class="text02" style="padding-top:8px;"><a href="<?php echo $rows->banner_url;?>" class="su" target="_blank"><strong><?php echo $rows->banner_name;?> [<?php echo $rows->banner_exp1;?>]</strong></a></td>
							  </tr>
							  <tr>
								<td class="text02" style="padding-top:8px;"><table width="0" border="0" cellspacing="0" cellpadding="0">
									<tr>
									  <td class="text02"><?php echo $rows->banner_exp2;?></td>
									  <td width="14" align="center" class="text02">ㅣ</td>
									 <!--  <td class="text02"><?php echo $row->category_name;?>[<?php echo $row->category_hanja;?>]</td>
									  <td width="14" align="center" class="text02">ㅣ</td> -->
									  <td class="text02"><?php echo $rows->banner_exp3;?></td>
									  <td width="14" align="center" class="text02">ㅣ</td>
									  <td class="text02"><?php echo $rows->banner_exp4;?></td>
									</tr>
								</table></td>
							  </tr>
						  </table></td>
				  <?php if($i+1==$total):?>
					<?php for ( $j=0; $j<3-($i%4); $j++) :?>
					  <td width="25" valign="top" style="padding-bottom:30px;">&nbsp</td>
					<?php endfor;?>
				  <?php endif;?>
				  <?php if($i%4==3):?>
						</tr>
					  </table>
				  <?php endif;?>
				  <?php $i++;?>
				<?php endwhile;?>
			  <?php endif;?>
			  <?php if(($i-1)%4!=3):?>
				</tr>
			  </table>
			  <?php endif;?>
		  </td>
		</tr>
		<!--<tr>
		  <td align="center">
			<?php if ($total > 0) : ?>
				<table cellspacing="0" cellpadding="0">
				  <tr>
					<td width="20">
					  <?php if($stpage-10>0): ?>
					    <a href="<?=$_SERVER["PHP_SELF"]?>?page=<?=$stpage-10?>&amp;<?=$addStr?>">
					      <img height="7" src="img/board/btn_prev_01.gif" width="9" align="absmiddle" border="0" />
						</a>
					  <?php endif;?>
					</td>
					<td width="20">
					  <a href="<?=$_SERVER["PHP_SELF"]?>?page=1&amp;<?=$addStr?>">
					    <img height="7" src="img/board/btn_prev_02.gif" width="5" align="absmiddle" border="0" />
					  </a>
					</td>
					<td align="middle" class="dbpaging">
					<?
						for($i=$stpage; ($i<=$edpage && $i<=$lastpage); $i++) {
							if($i<0)
							{
								continue;
							}
							if($i==$page)
							{
								echo "<a href='".$_SERVER['PHP_SELF']."?page=$i&amp;$addStr'><span class='dbbold'>".$i."</span></a>";
							}else{
								echo "<a href='".$_SERVER['PHP_SELF']."?page=$i&amp;$addStr' class='dblink'>".$i."</a>";
							}
						}
					?>
					</td>
					<td width="20" align="right">
					  <a href="<?=$_SERVER["PHP_SELF"]?>?page=<?=$lastpage?>&amp;<?=$addStr?>">
						<img src="img/board/btn_next_02.gif" width="5" height="7" border="0" align="absmiddle" />
					  </a>
					</td>
					<td width="20" align="right">
					  <?php if ($edpage < $lastpage):?>
					    <a href="<?=$_SERVER["PHP_SELF"]?>?page=<?=$stpage+10?>&amp;<?=$addStr?>">
						  <img height="7" src="img/board/btn_next_01.gif" width="9" align="absmiddle" border="0" />
					    </a>
					  <?php endif;?>
					</td>
				  </tr>
				</table>
			<?php endif?>
		  </td>
		</tr>-->
	</table>
<? include "inc/inc_footer.php" ?><!-- footer -->
